package healthylife.top.sync;

import io.minio.MinioClient;

public class FileSyncServiceFactory {

    public static FileSyncService ins(FileServerType fileServerType) {
        switch (fileServerType) {
            case LOCAL:
                return new LocalFileClient("D:\\Program Files", "E:\\test-bak", "D:\\sync");
            case MINIO:
                return new MinioSyncClient("hengtian", "private", "D:\\sync-hengtian-temp", "D:\\sync");
            case GFSSYNC:
                return gfsSyncClient();
            default:
            //  nothing
                throw new RuntimeException("尚未实现");
        }
    }

    private static GFSSyncClient gfsSyncClient() {
        GFSSyncClient.SourceClient sourceClient = new GFSSyncClient.SourceClient();
        sourceClient.rootFolderId = "0";
        sourceClient.rootFolderName = "ROOT";
        sourceClient.host = "http:xxxxx";
        sourceClient.loginName = "xxx";
        sourceClient.integrationKey = "xx";
        GFSSyncClient.TargetClient targetClient = new GFSSyncClient.TargetClient();
        targetClient.minioAccessKey = "";
        targetClient.minioSecretKey = "";
        targetClient.minioClient = MinioClient.builder()
                .endpoint(targetClient.minioEndpoint)
                .credentials(targetClient.minioAccessKey, targetClient.minioSecretKey)
                .build();
      return   new GFSSyncClient(sourceClient, targetClient, "D:\\sync-gfs\\temp", "D:\\sync-gfs");
    }

  public enum FileServerType {
        LOCAL,
        MINIO,
        GFSSYNC,
    }
}
